﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WebServer.DBUtility;
using WebServer.Models;

namespace WebServer.DBAccess
{
    public class BarDA
    {
        #region 邮吧 [列表、根据ID查询、增/改、动作、排序]
        /// <summary>
        /// 邮吧
        /// </summary>
        /// <param name="PageSize">每页行数</param>
        /// <param name="Page">页码</param>
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="IsUserID">登录用户ID【是否只查询自己的数据】</param>
        /// <param name="Commend">是否推荐</param>
        /// <param name="Img">是否强制有图片</param>
        /// <param name="IsTv">是否为直播</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<Bar> NBarSearch(int PageSize, int Page, int Come, string CenterID, string Code, int UserID, int IsUserID,int UserCate, bool IsExpert, bool Commend, bool IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (Page - 1) * PageSize, Come, CenterID, Code, UserID, IsUserID,UserCate,IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_Q]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();

                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.REID = reader[25].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.RECate = reader[26].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[27].ToString();
                        entity.RESmallTitle = reader[28].ToString();
                        if (reader[29] != DBNull.Value)
                            entity.RECreateTime = reader[29].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[30].ToString();
                        if (reader[31] != DBNull.Value)
                            entity.ReHits = reader[31].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[32] != DBNull.Value)
                            entity.ReTotal = reader[32].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[33] != DBNull.Value)
                            entity.TranTotal = reader[33].ToInt32();
                        else
                            entity.TranTotal = 0;
                        if (reader[34] != DBNull.Value)
                            entity.RowNumber = reader[34].ToInt32();
                        else
                            entity.RowNumber = -1;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        /// 自己以及自己关注的人发的邮吧
        /// </summary>
        /// <param name="PageSize">每页行数</param>
        /// <param name="Page">页码</param>
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="IsUserID">登录用户ID【是否只查询自己的数据】</param>
        /// <param name="Commend">是否推荐</param>
        /// <param name="Img">是否强制有图片</param>
        /// <param name="IsTv">是否为直播</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<Bar> UBarSearch(int PageSize, int Page, int Come, string CenterID, string Code, int UserID, int IsUserID, int UserCate, bool IsExpert, bool Commend, bool IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (Page - 1) * PageSize, Come, CenterID, Code, UserID, IsUserID, UserCate, IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_UQ]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();

                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.REID = reader[25].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.RECate = reader[26].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[27].ToString();
                        entity.RESmallTitle = reader[28].ToString();
                        if (reader[29] != DBNull.Value)
                            entity.RECreateTime = reader[29].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[30].ToString();
                        if (reader[31] != DBNull.Value)
                            entity.ReHits = reader[31].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[32] != DBNull.Value)
                            entity.ReTotal = reader[32].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[33] != DBNull.Value)
                            entity.TranTotal = reader[33].ToInt32();
                        else
                            entity.TranTotal = 0;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        /// 可模糊查询邮吧
        /// </summary>
        /// <param name="PageSize">每页行数</param>
        /// <param name="Page">页码</param>
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="IsUserID">是否根据用户查询</param>
        /// <param name="Text">内容</param>
        /// <param name="Commend">是否推荐</param>
        /// <param name="Img">是否强制有图片</param>
        /// <param name="IsTv">是否为直播</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<Bar> MBarSearch(int PageSize, int Page, int Come, string CenterID, string Code, int UserID,  string Text, int UserCate, bool IsExpert, bool Commend, bool IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (Page - 1) * PageSize, Come, CenterID, Code, UserID,  Text, UserCate, IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_MQ]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.REID = reader[25].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.RECate = reader[26].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[27].ToString();
                        entity.RESmallTitle = reader[28].ToString();
                        if (reader[29] != DBNull.Value)
                            entity.RECreateTime = reader[29].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[30].ToString();
                        if (reader[31] != DBNull.Value)
                            entity.ReHits = reader[31].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[32] != DBNull.Value)
                            entity.ReTotal = reader[32].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[33] != DBNull.Value)
                            entity.TranTotal = reader[33].ToInt32();
                        else
                            entity.TranTotal = 0;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        /// 可模糊查询指定多人的邮吧
        /// </summary>
        /// <param name="PageSize">每页行数</param>
        /// <param name="Page">页码</param>
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="IsUserID">是否根据用户查询</param>
        /// <param name="Text">内容</param>
        /// <param name="Commend">是否推荐</param>
        /// <param name="Img">是否强制有图片</param>
        /// <param name="IsTv">是否为直播</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<Bar> EBarSearch(int PageSize, int Page, int Come, string CenterID, string Code, int UserID, string IsUserID, string Text, int UserCate, bool IsExpert, bool Commend, bool IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (Page - 1) * PageSize, Come, CenterID, Code, UserID, IsUserID, Text, UserCate, IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_Exclusive]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.REID = reader[25].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.RECate = reader[26].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[27].ToString();
                        entity.RESmallTitle = reader[28].ToString();
                        if (reader[29] != DBNull.Value)
                            entity.RECreateTime = reader[29].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[30].ToString();
                        if (reader[31] != DBNull.Value)
                            entity.ReHits = reader[31].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[32] != DBNull.Value)
                            entity.ReTotal = reader[32].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[33] != DBNull.Value)
                            entity.TranTotal = reader[33].ToInt32();
                        else
                            entity.TranTotal = 0;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }



        /// <summary>
        /// 邮吧总数
        /// </summary>
        /// <param name="Come"></param>
        /// <param name="CenterID"></param>
        /// <param name="Code"></param>
        /// <param name="UserID"></param>
        /// <param name="Text"></param>
        /// <param name="UserCate"></param>
        /// <param name="IsExpert"></param>
        /// <param name="Commend"></param>
        /// <param name="IsTv"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static int EBarCount(int Come, string CenterID, string Code, int UserID, string IsUserID, string Text, int UserCate, bool IsExpert, bool Commend, bool IsTv, int IsDel)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { Come, CenterID, Code, UserID, IsUserID, Text, UserCate, IsExpert, Commend, IsTv, IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_ExclusiveC]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        /// <summary>
        /// 手机可模糊查询邮吧
        /// </summary>
        /// <param name="OpenTime">开始时间</param>
        /// <param name="EndTime">截止时间</param>
        /// <param name="PageSize">每页行数</param>      
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="Text">内容</param>
        /// <param name="UserCate">用户类型，0-普通，1-分析师，2-经济商</param>
        /// <param name="IsExpert">0为不是专家，1为专家，-1为全部</param>
        /// <param name="Commend">0为未推荐，1为已推荐，-1为全部</param>    
        /// <param name="IsTv">0为不是直播，1为直播，-1为全部</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">0为未删除，1为已删除，-1为全部</param>
        /// <returns></returns>
        public static List<Bar> PBarSearch(string OpenTime, string EndTime, int PageSize, int Come, string CenterID, string Code, int UserID, int IsUser, string Text, int UserCate, int IsExpert, int Commend, int IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { OpenTime, EndTime, PageSize, Come, CenterID, Code, UserID, IsUser, Text, UserCate, IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_PQ]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.REID = reader[25].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.RECate = reader[26].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[27].ToString();
                        entity.RESmallTitle = reader[28].ToString();
                        if (reader[29] != DBNull.Value)
                            entity.RECreateTime = reader[29].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[30].ToString();
                        if (reader[31] != DBNull.Value)
                            entity.ReHits = reader[31].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[32] != DBNull.Value)
                            entity.ReTotal = reader[32].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[33] != DBNull.Value)
                            entity.TranTotal = reader[33].ToInt32();
                        else
                            entity.TranTotal = 0;
                        if (reader[34] != DBNull.Value)
                            entity.RowNumber = reader[34].ToInt32();
                        else
                            entity.RowNumber = -1;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }



        /// <summary>
        /// 邮吧总数
        /// </summary>
        /// <param name="Come"></param>
        /// <param name="CenterID"></param>
        /// <param name="Code"></param>
        /// <param name="UserID"></param>
        /// <param name="Text"></param>
        /// <param name="UserCate"></param>
        /// <param name="IsExpert"></param>
        /// <param name="Commend"></param>
        /// <param name="IsTv"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static int MBarCount(int Come, string CenterID, string Code, int UserID, string Text, int UserCate, bool IsExpert, bool Commend, bool IsTv,int IsDel)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { Come, CenterID, Code, UserID, Text, UserCate, IsExpert, Commend, IsTv, IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_MC]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }



        /// <summary>
        /// 根据邮吧ID获取信息
        /// </summary>
        /// <param name="ID">邮吧ID</param>
        /// <param name="UserID">用户ID</param>
        /// <returns></returns>
        public static Bar GetBarByID(int? ID = 0, int? UserID = 0)
        {
            Bar entity = new Bar();
            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_ByID]", new object[] { ID, UserID }))
                {
                    while (reader.Read())
                    {

                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.IsDel = reader[23].ToBoolean();
                        else
                            entity.IsDel = false;
                        entity.Img = reader[24].ToString();
                        if (reader[25] != DBNull.Value)
                            entity.CateID = reader[25].ToInt32();
                        else
                            entity.CateID = 0;
                        if (reader[26] != DBNull.Value)
                            entity.REID = reader[26].ToInt32();
                        else
                            entity.REID = 0;
                        if (reader[27] != DBNull.Value)
                            entity.RECate = reader[27].ToInt32();
                        else
                            entity.RECate = 0;
                        entity.RETitle = reader[28].ToString();
                        entity.RESmallTitle = reader[29].ToString();
                        if (reader[30] != DBNull.Value)
                            entity.RECreateTime = reader[30].ToDateTime();
                        else
                            entity.RECreateTime = DateTime.Now;
                        entity.REUrl = reader[31].ToString();
                        if (reader[32] != DBNull.Value)
                            entity.ReHits = reader[32].ToInt32();
                        else
                            entity.ReHits = 0;
                        if (reader[33] != DBNull.Value)
                            entity.ReTotal = reader[33].ToInt32();
                        else
                            entity.ReTotal = 0;
                        if (reader[34] != DBNull.Value)
                            entity.TranTotal = reader[34].ToInt32();
                        else
                            entity.TranTotal = 0;
                        if (reader[35] != DBNull.Value)
                            entity.RowNumber = reader[35].ToInt32();
                        else
                            entity.RowNumber = -1;
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entity;
        }

        /// <summary>
        /// 新增或者修改邮吧
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddOrUpBar(Bar model)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] WhereInfo = new object[] { model.ID, model.UserID, model.Text, model.Origin, model.Come, model.CreateTime, model.Goods, model.Hits, model.Type, model.IsDel, model.Commend, model.CenterID, model.Code, model.Img, model.Url, model.IsTv, model.IfTran };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_Set]", WhereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 邮吧动作
        /// </summary>
        /// <param name="ID">邮吧ID</param>
        /// <param name="Filed">列名</param>
        /// <param name="Fn">值</param>
        /// <returns></returns>
        public static int BarAction(int ID, string Filed, bool Fn)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] WhereInfo = new object[] { ID, Filed, Fn };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_Action]", WhereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 邮吧排序
        /// </summary>
        /// <param name="Size">显示多少行</param>
        /// <param name="Sort">排序1-ID，2-创建时间，3-修改时间，4-转发总数，5-回复总数，默认点击总数</param>
        /// <param name="Desc">是否倒序</param>
        /// <returns></returns>
        public static List<Bar> NBarSort(int Size,int Sort,bool Desc)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { Size, Sort ,Desc};

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_Sort]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;                     
                        entity.Text = reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.Come = reader[2].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[3].ToString();
                        entity.Code = reader[4].ToString();
                        entity.Img = reader[5].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        #endregion

        #region 邮吧回复列表、增
        /// <summary>
        /// 邮吧回复列表
        /// </summary>
        /// <param name="PageSize">，每页行数</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="BarID">邮吧ID</param>
        /// <param name="UserID">用户ID</param>
        /// <param name="OrderInfo">排序条件</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<BarReply> NBarReplySearch(int PageSize = 8, int PageIndex = 1, int BarID = 0, int UserID = 0, int OrderInfo = 0, string DescInfo = "", int IsDel = 0)
        {
            List<BarReply> entitys = new List<BarReply>();

            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (PageIndex - 1) * PageSize, BarID, UserID, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_reply_ByBarID]", obj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CateID = reader[7].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.OnlogIP = reader[8].ToString();
                        entity.Portrait = reader[9].ToString();
                        if (reader[10] != DBNull.Value)
                            entity.IsOpen = reader[10].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[11] != DBNull.Value)
                            entity.Score = reader[11].ToInt32();
                        else
                            entity.Score = 0;
                        entity.Img = reader[12].ToString();
                        entity.Voice = reader[13].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }


        /// <summary>
        /// 邮吧回复列表
        /// </summary>
        /// <param name="PageSize">，每页行数</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="BarID">邮吧ID</param>
        /// <param name="UserID">用户ID</param>
        /// <param name="OrderInfo">排序条件</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">是否删除</param>
        /// <returns></returns>
        public static List<BarReply> PBarReplySearch(string OpenTime="",string EndTime="",int PageSize = 8, int BarID = 0, int UserID = 0, int OrderInfo = 0, string DescInfo = "", int IsDel = 0)
        {
            List<BarReply> entitys = new List<BarReply>();

            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { OpenTime, EndTime , PageSize, BarID, UserID, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_reply_PByBarID]", obj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CateID = reader[7].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.OnlogIP = reader[8].ToString();
                        entity.Portrait = reader[9].ToString();
                        if (reader[10] != DBNull.Value)
                            entity.IsOpen = reader[10].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[11] != DBNull.Value)
                            entity.Score = reader[11].ToInt32();
                        else
                            entity.Score = 0;
                        entity.Img = reader[12].ToString();
                        entity.Voice = reader[13].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        ///  邮吧回复总数
        /// </summary>
        /// <param name="BarID"></param>
        /// <param name="UserID"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static int NBarReplyCount(int BarID = 0, int UserID = 0,  int IsDel = 0)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { BarID, UserID,  IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_replyC_ByBarID]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }



        /// <summary>
        /// 回复邮吧
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int ReplyBar(BarReply entity)
        {
            try
            {
                object[] whereInfo = new object[] { entity.ID,entity.UserID, entity.BarID, entity.Text ,entity.CreateTime,entity.Img,entity.Voice,entity.IsDel,entity.Origin};
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_reply_A]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 删除回复信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static int DelRelyBar(int ID)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_reply_D]", ID);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 根據Id獲取郵吧回復
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static BarReply ReplyBarByID(int ID = 0)
        {
            BarReply entity = new BarReply();
            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_reply_ByID]", new object[] { ID }))
                {
                    while (reader.Read())
                    {

                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CateID = reader[7].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.OnlogIP = reader[8].ToString();
                        entity.Portrait = reader[9].ToString();
                        if (reader[10] != DBNull.Value)
                            entity.IsOpen = reader[10].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[11] != DBNull.Value)
                            entity.Score = reader[11].ToInt32();
                        else
                            entity.Score = 0;
                        entity.Img = reader[12].ToString();
                        entity.Voice = reader[13].ToString();
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entity;
        }


        #endregion

        #region 直播室
        /// <summary>
        /// 直播室内人员列表
        /// </summary>
        /// <param name="DtTime"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="UserId"></param>
        /// <param name="UserName"></param>
        /// <param name="BarID"></param>
        /// <param name="Order">默认根据时间排序，1-ID，2-USerID，3-BarID</param>
        /// <param name="Desc"></param>
        /// <returns></returns>
        public static List<UToLive> ToLiveList(int PageSize = 8, int PageIndex = 1, int UserId = 0, string UserName = "", int BarID = 0, int DtTime=0, int Order = 0, bool Desc = true)
        {
            List<UToLive> entitys = new List<UToLive>();
            try {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { PageSize, (PageIndex - 1) * PageSize, UserId, UserName, BarID, DtTime, Order, Desc };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_U_ToLive_Q]", tiaoj))
                {
                    UToLive entity = null;
                    while (reader.Read())
                    {
                        entity = new UToLive();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        entity.UserName = reader[2].ToString();
                        entity.Portrait = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.BarID = reader[4].ToInt32();
                        else
                            entity.BarID = 0;
                        if (reader[5] != DBNull.Value)
                            entity.CreateTime = reader[5].ToDateTime();
                        else
                            entity.CreateTime =DateTime.Now;
                        if (reader[6] != DBNull.Value)
                            entity.IsBanned = reader[6].ToBoolean();
                        else
                            entity.IsBanned = false;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch(Exception ex)
            {
            }

            return entitys;
        }

        /// <summary>
        /// 进入直播室
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int ToLiveSet(UToLive entity)
        {
            try
            {
                object[] whereInfo = new object[] { entity.UserID, entity.UserName,entity.Portrait, entity.BarID};
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_Set]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
        /// <summary>
        /// 退出直播室
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="UserName"></param>
        /// <param name="BarID"></param>
        /// <returns></returns>
        public static int ToLiveOut(int UserID,string UserName,int BarID)
        {
            try
            {
                object[] whereInfo = new object[] { UserID, UserName, BarID };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_Out]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        ///热门直播室
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public static List<Bar> getHotLiveRoom(int pageSize = 8, int PageIndex = 1)
        {
            List<Bar> entitys = new List<Bar>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();

                object[] tiaoj = new object[] { pageSize, (PageIndex - 1) * pageSize };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_LiveRoom_Hot]", tiaoj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        entity.Name = reader[0].ToString();
                        entity.Text =reader[1].ToString();
                        if (reader[2] != DBNull.Value)
                            entity.ID = reader[2].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Discuss = reader[3].ToInt32();
                        if (reader[4] != DBNull.Value)
                            entity.Score =reader[4].ToInt32();
                        else
                           entity.Score = 0;
                        if (reader[5] != DBNull.Value)
                            entity.CateID = reader[5].ToInt32();
                        else
                            entity.CateID = 0;
                        if (reader[6] != DBNull.Value)
                            entity.IsOpen = reader[6].ToInt32();
                        else
                            entity.IsOpen = 0;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }                
            }
            catch (Exception ex)
            {

            }
            return entitys;
        }

        /// <summary>
        ///首次直播内容
        /// </summary>
        /// <param name="Userid"></param>
        /// <param name="BarID"></param>
        /// <param name="Order">默认根据时间排序，1-barid，2-userid</param>
        /// <returns></returns>
        public static List<BarReply> HomeLiveTalk(int Userid, string UserName, int BarID, int Top, int Order, bool Desc, bool IsDel)
        {
            List<BarReply> entitys = new List<BarReply>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();

                object[] tiaoj = new object[] { Userid, UserName, BarID, Top, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_LiveRoom_HomeQ]", tiaoj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        //entity.Text = Common.Clearchar(entity.Text);
                        ////if (entity.Text.Length > 35)
                        ////{
                        ////    entity.Text = entity.Text.Substring(0, 33) + "...";
                        ////}
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        entity.Introduce = reader[7].ToString();
                        entity.Portrait = reader[8].ToString();
                        entity.Img = reader[9].ToString();
                        entity.Voice = reader[10].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        ///刷新直播内容
        /// </summary>
        /// <param name="Userid"></param>
        /// <param name="BarID"></param>
        /// <param name="Order">默认根据时间排序，1-barid，2-userid</param>
        /// <returns></returns>
        public static List<BarReply> LiveTalkB(string beginTime, int Userid, string UserName, int BarID, int Top,int Order, bool Desc, bool IsDel)
        {
            List<BarReply> entitys = new List<BarReply>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();

                object[] tiaoj = new object[] { beginTime, Userid, UserName, BarID,Top, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_LiveRoom_BQ]", tiaoj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        //entity.Text = Common.Clearchar(entity.Text);
                        ////if (entity.Text.Length > 35)
                        ////{
                        ////    entity.Text = entity.Text.Substring(0, 33) + "...";
                        ////}
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        entity.Introduce = reader[7].ToString();
                        entity.Portrait = reader[8].ToString();
                        entity.Img = reader[9].ToString();
                        entity.Voice = reader[10].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return entitys;
        }



        /// <summary>
        ///历史直播内容
        /// </summary>
        /// <param name="Userid"></param>
        /// <param name="BarID"></param>
        /// <param name="Order">默认根据时间排序，1-barid，2-userid</param>
        /// <returns></returns>
        public static List<BarReply> LiveTalkE(string endTime, int Userid, string UserName, int BarID, int Top, int Order, bool Desc, bool IsDel)
        {
            List<BarReply> entitys = new List<BarReply>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();

                object[] tiaoj = new object[] { endTime, Userid, UserName, BarID, Top, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_LiveRoom_EQ]", tiaoj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        //entity.Text = Common.Clearchar(entity.Text);
                        ////if (entity.Text.Length > 35)
                        ////{
                        ////    entity.Text = entity.Text.Substring(0, 33) + "...";
                        ////}
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        entity.Introduce = reader[7].ToString();
                        entity.Portrait = reader[8].ToString();
                        entity.Img = reader[9].ToString();
                        entity.Voice = reader[10].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return entitys;
        }


        /// <summary>
        ///直播内容2
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="Userid"></param>
        /// <param name="BarID"></param>
        /// <param name="Order">默认根据时间排序，1-barid，2-userid</param>
        /// <returns></returns>
        public static List<BarReply> MasterLive(int PageSize, int PageIndex, int Userid, int BarID, int Order, bool Desc, bool IsDel)
        {
            List<BarReply> entitys = new List<BarReply>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();

                object[] tiaoj = new object[] { PageSize, (PageIndex - 1) * PageSize, Userid, BarID, Order, Desc, IsDel };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_LiveRoom]", tiaoj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        //entity.Text = Common.Clearchar(entity.Text);
                        ////if (entity.Text.Length > 35)
                        ////{
                        ////    entity.Text = entity.Text.Substring(0, 33) + "...";
                        ////}
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        entity.Introduce = reader[7].ToString();
                        entity.Img = reader[8].ToString();
                        entity.Voice = reader[9].ToString();

                        entitys.Add(entity);
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        /// 播主对某人禁言
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="UserName"></param>
        /// <param name="BarID"></param>
        /// <param name="Fild"></param>
        /// <param name="Fn"></param>
        /// <returns></returns>
        public static int BannedPeo(int ID, int UserID, string UserName, int BarID, string Fild, bool Fn)
        {
            try
            {
                object[] whereInfo = new object[] { ID, UserID, UserName, BarID, Fild, Fn };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_Action]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 是否被禁用
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="UserName"></param>
        /// <param name="BarID"></param>
        /// <returns></returns>
        public static int IfBanned(int UserID, string UserName, int BarID)
        {
            try
            {
                object[] whereInfo = new object[] {  UserID, UserName, BarID };
                SQLHelper sqlHelp = new SQLHelper();
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_B]", whereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
 
        }

        /// <summary>
        /// 历史直播室
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="Page"></param>
        /// <param name="UserID"></param>
        /// <param name="Commend"></param>
        /// <param name="OrderInfo"></param>
        /// <param name="DescInfo"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static List<Bar> HistoryLiveByUserID(int PageSize, int Page, int UserID, bool Commend, int OrderInfo, bool DescInfo,int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, (Page - 1) * PageSize, UserID, Commend, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_HTv]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                        {
                            entity.IsDel = reader[23].ToBoolean();
                        }
                        else
                            entity.IsDel = false;
                        if (reader[24] != DBNull.Value)
                            entity.RowNumber = reader[24].ToInt32();
                        else
                            entity.RowNumber = -1;
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }

        /// <summary>
        /// 历史直播总数
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="Commend"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public static int HistoryLiveCountByUserID(int UserID, bool Commend, int IsDel)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { UserID, Commend, IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Bar_CTv]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        /// <summary>
        /// 新增或者修改直播室
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddOrUpLive(Bar model)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] WhereInfo = new object[] { model.ID, model.UserID, model.Text, model.Origin, model.Come, model.CreateTime, model.Goods, model.Hits, model.Type, model.IsDel, model.Commend, model.CenterID, model.Code, model.Img, model.Url, model.IsTv, model.IfTran };
                object obj = sqlHelp.ExecuteSPScalar("[sp_LiveRoom_Set]", WhereInfo);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        /// <summary>
        /// 显示被禁止发言人的信息
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="IsBanned"></param>
        /// <param name="UserName"></param>
        /// <param name="Order"></param>
        /// <param name="Desc"></param>
        /// <returns></returns>
        public static List<UToLive> AuditList(int PageSize=10,int PageIndex=1,int IsBanned=2,string UserName = "", int Order = 0, bool Desc = true)
        {
            List<UToLive> entitys = new List<UToLive>();
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { PageSize, (PageIndex - 1) * PageSize, IsBanned, UserName, Order, Desc };
                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_U_ToLive_AuditQ]", tiaoj))
                {
                    UToLive entity = null;
                    while (reader.Read())
                    {
                        entity = new UToLive();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        entity.UserName = reader[2].ToString();
                        entity.Portrait = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.BarID = reader[4].ToInt32();
                        else
                            entity.BarID = 0;
                        if (reader[5] != DBNull.Value)
                            entity.CreateTime = reader[5].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[6] != DBNull.Value)
                        {
                            entity.IsBanned = reader[6].ToBoolean();
                        }
                        else
                            entity.IsBanned = false;
                        entity.BarText = reader[7].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }

            return entitys;
        }

        /// <summary>
        /// 显示被禁止发言人的信息总数
        /// </summary>
        /// <param name="IsBanned"></param>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public static int AuditCount(int IsBanned = 2, string UserName = "")
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { IsBanned, UserName };
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_MC]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 给邮吧添加游客
        /// </summary>
        /// <param name="BarID"></param>
        /// <param name="Count"></param>
        /// <param name="CreaTime"></param>
        /// <returns></returns>
        public static int AuditAdd(int BarID, int Count, DateTime CreaTime)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { BarID, Count, CreaTime };
                object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_Add]", tiaoj);
                return 1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }


        ///// <summary>
        ///// 对某人在某某邮吧内允许发言
        ///// </summary>
        ///// <param name="ID"></param>
        ///// <returns></returns>
        //public static int AllowSpeak(int ID,string Fnile,bool Fn)
        //{
        //    try
        //    {
        //        SQLHelper sqlHelp = new SQLHelper();
        //        object obj = sqlHelp.ExecuteSPScalar("[sp_U_ToLive_Au]", new object[] { ID, Fnile, Fn });
        //        if (obj != null && obj != DBNull.Value)
        //        {
        //            return Convert.ToInt32(obj);
        //        }
        //        else
        //            return -1;
        //    }
        //    catch (Exception ex)
        //    {
        //        return -1;
        //    }
        //}


        /// <summary>
        /// 根据博主是否在，判断直播显示开启或关闭
        /// </summary>
        /// <param name="BarID"></param>
        /// <returns></returns>
        public int LiveExp(int BarID,int IsExp)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { BarID, IsExp };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Live_Exp]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
        #endregion

        #region 其他评论产生的邮吧列表
         /// <summary>
        /// 手机可模糊查询评论列表
        /// </summary>
        /// <param name="OpenTime">开始时间</param>
        /// <param name="EndTime">截止时间</param>
        /// <param name="PageSize">每页行数</param>      
        /// <param name="Come">来源，全部为可能0或空</param>
        /// <param name="CenterID">根据来源来区分关联ID，默认为可能0或空</param>
        /// <param name="Code">藏品ID，默认为可能0或</param>
        /// <param name="UserID">登录用户ID【判断是否收藏，转发过】</param>
        /// <param name="Text">内容</param>
        /// <param name="UserCate">用户类型，0-普通，1-分析师，2-经济商</param>
        /// <param name="IsExpert">0为不是专家，1为专家，-1为全部</param>
        /// <param name="Commend">0为未推荐，1为已推荐，-1为全部</param>    
        /// <param name="IsTv">0为不是直播，1为直播，-1为全部</param>
        /// <param name="OrderInfo">排序条件1-CreateTime/2-UserID/3-Come/4-Goods/5-Hits</param>
        /// <param name="DescInfo">传入'Desc'降序,'Asc'升序,或者默认为空</param>
        /// <param name="IsDel">0为未删除，1为已删除，-1为全部</param>
        /// <returns></returns>
        public static List<Bar> PreplyList(string OpenTime, string EndTime, int PageSize, int Come, string CenterID, string Code, int UserID, int IsUser, string Text, int UserCate, int IsExpert, int Commend, int IsTv, int OrderInfo, bool DescInfo, int IsDel)
        {
            List<Bar> entitys = new List<Bar>();

            try
            {

                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { OpenTime, EndTime, PageSize, Come, CenterID, Code, UserID, IsUser, Text, UserCate, IsExpert, Commend, IsTv, OrderInfo, DescInfo, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Bar_PQByCenterID]", obj))
                {
                    Bar entity = null;
                    while (reader.Read())
                    {
                        entity = new Bar();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        entity.Name = reader[1].ToString();
                        entity.Text = reader[2].ToString();
                        entity.Commend = reader[3].ToBoolean();
                        if (reader[4] != DBNull.Value)
                            entity.Goods = reader[4].ToInt32();
                        else
                            entity.Goods = 0;
                        if (reader[5] != DBNull.Value)
                            entity.Hits = reader[5].ToInt32();
                        else
                            entity.Hits = 0;
                        if (reader[6] != DBNull.Value)
                            entity.TranInfo = reader[6].ToInt32();
                        else
                            entity.TranInfo = 0;
                        if (reader[7] != DBNull.Value)
                            entity.UserID = reader[7].ToInt32();
                        else
                            entity.UserID = 0;
                        //if (reader[8] != DBNull.Value)
                        //    entity.Origin = reader[8].ToInt32();
                        //else
                        //    entity.Origin = 0;
                        if (reader[9] != DBNull.Value)
                            entity.CreateTime = reader[9].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[10] != DBNull.Value)
                            entity.Type = reader[10].ToInt32();
                        else
                            entity.Type = 0;
                        if (reader[11] != DBNull.Value)
                            entity.IsTv = reader[11].ToBoolean();
                        else
                            entity.IsTv = false;
                        if (reader[12] != DBNull.Value)
                            entity.Come = reader[12].ToInt32();
                        else
                            entity.Come = 0;
                        entity.CenterID = reader[13].ToString();
                        entity.Code = reader[14].ToString();
                        if (reader[15] != DBNull.Value)
                            entity.CollectID = reader[15].ToInt32();
                        else
                            entity.CollectID = 0;
                        if (reader[16] != DBNull.Value)
                            entity.OptInID = reader[16].ToInt32();
                        else
                            entity.OptInID = 0;
                        if (reader[17] != DBNull.Value)
                            entity.Discuss = reader[17].ToInt32();
                        else
                            entity.Discuss = 0;
                        if (reader[18] != DBNull.Value)
                            entity.IfTran = reader[18].ToInt32();
                        else
                            entity.IfTran = 0;
                        entity.OnlogIP = reader[19].ToString();
                        entity.Portrait = reader[20].ToString();
                        if (reader[21] != DBNull.Value)
                            entity.IsOpen = reader[21].ToInt32();
                        else
                            entity.IsOpen = 0;
                        if (reader[22] != DBNull.Value)
                            entity.Score = reader[22].ToInt32();
                        else
                            entity.Score = 0;
                        if (reader[23] != DBNull.Value)
                            entity.CateID = reader[23].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.Img = reader[24].ToString();
                       
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }
        
        #endregion

        #region 新的直播【邮吧回复】
        /// <summary>
        /// 新直播
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int NLiveAdd(BarReply entity)
        {
            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] tiaoj = new object[] { entity.ID, entity.UserID, entity.Name, entity.BarID, entity.Text, entity.Origin, entity.Voice, entity.Img, entity.CreateTime, entity.IsDel };
                object obj = sqlHelp.ExecuteSPScalar("[sp_N_Live_Add]", tiaoj);
                if (obj != null && obj != DBNull.Value)
                {
                    return Convert.ToInt32(obj);
                }
                else
                    return -1;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        /// <summary>
        /// 新的直播列表
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="MaxID"></param>
        /// <param name="MinID"></param>
        /// <param name="Order"></param>
        /// <param name="LiveID"></param>
        /// <param name="IsDel"></param>
        /// <returns></returns>
        public List<BarReply> NLiveSearch(int PageSize = 8, int MaxID = 0, int MinID = 0, int Order = 0, int LiveID = 0, int IsDel = 0)
        {
            List<BarReply> entitys = new List<BarReply>();

            try
            {
                SQLHelper sqlHelp = new SQLHelper();
                object[] obj = new object[] { PageSize, MaxID, MinID, Order, LiveID, IsDel };

                using (IDataReader reader = sqlHelp.ExecuteReader("[sp_N_Live_Q]", obj))
                {
                    BarReply entity = null;
                    while (reader.Read())
                    {
                        entity = new BarReply();
                        if (reader[0] != DBNull.Value)
                            entity.ID = reader[0].ToInt32();
                        else
                            entity.ID = 0;
                        if (reader[1] != DBNull.Value)
                            entity.UserID = reader[1].ToInt32();
                        else
                            entity.UserID = 0;
                        if (reader[2] != DBNull.Value)
                            entity.BarID = reader[2].ToInt32();
                        else
                            entity.BarID = 0;
                        entity.Text = reader[3].ToString();
                        if (reader[4] != DBNull.Value)
                            entity.CreateTime = reader[4].ToDateTime();
                        else
                            entity.CreateTime = DateTime.Now;
                        if (reader[5] != DBNull.Value)
                            entity.Origin = reader[5].ToInt32();
                        else
                            entity.Origin = 0;
                        entity.Name = reader[6].ToString();
                        if (reader[7] != DBNull.Value)
                            entity.CateID = reader[7].ToInt32();
                        else
                            entity.CateID = 0;
                        entity.OnlogIP = reader[8].ToString();
                        entity.Portrait = reader[9].ToString();                      
                        if (reader[10] != DBNull.Value)
                            entity.Score = reader[10].ToInt32();
                        else
                            entity.Score = 0;
                        entity.Img = reader[11].ToString();
                        entity.Voice = reader[12].ToString();
                        entitys.Add(entity);
                    }

                    reader.Close();
                }

            }
            catch (Exception ex)
            {
            }
            return entitys;
        }
        #endregion
    }
}
